<template>
  <div class="body">
    <div class="container">
      <div class="card">
        <div class="content">
          <h2>01</h2>
          <h3>评估模块</h3>
          <p>
            Realistic glass card hover effect, realistic glass card hover
            effect, realistic glass card hover effect.
          </p>
          <a @click="goFrontHome()">进入模块</a>
        </div>
      </div>
      <div class="card">
        <div class="content">
          <h2>02</h2>
          <h3>教学模块</h3>
          <p>
            Realistic glass card hover effect, realistic glass card hover
            effect, realistic glass card hover effect.
          </p>
          <a href="#">进入模块</a>
        </div>
      </div>
      <div class="card">
        <div class="content">
          <h2>03</h2>
          <h3>学习板块</h3>
          <p>
            Realistic glass card hover effect, realistic glass card hover
            effect, realistic glass card hover effect, realistic glass card
            hover effect.
          </p>
          <a href="#">点击进入</a>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import VanillaTilt from "vanilla-tilt";
import { ref, onMounted } from "vue";
import { useRouter } from "vue-router";

const router = useRouter();

const goFrontHome = () => {
  router.push({ path: "/" });
};
onMounted(() => {
  // vanilla-tilt.js是一个平滑的3D倾斜JS库，具体参数配置度娘可查到
  VanillaTilt.init(document.querySelectorAll(".card"), {
    max: 15, //最大倾斜度数
    speed: 400, //倾斜转换的速度
    glare: true, //是否开启眩光效果
    "max-glare": 1, //最大眩光的不透明度
  });

  VanillaTilt.init(document.querySelectorAll(".card"));
});
</script>

<style scoped>
/* 引入网络字体：Poppins */
@import url("http://fonts.googleapis.com/css?family=Poppins:200,300,400,500,600,700,800,900&display=swap");
* {
  /* 初始化 */
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  /* 设置字体 */
  font-family: "Poppins";
}
.body {
  /* 100%窗口高度 */
  min-height: 100vh;
  /* 弹性布局 水平+垂直居中 */
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #161626;
}
/* 给背景增加两个渐变圆 */
.body::before {
  content: "";
  /* 绝对定位 */
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* 渐变背景 */
  background: linear-gradient(#2193b0, #6dd5ed);
  /* 将元素剪切微一个圆形【30%表示圆的直径】【right 70%表示圆心位置】 */
  clip-path: circle(30% at right 70%);
}
.body::after {
  content: "";
  /* 绝对定位 */
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* 渐变背景 */
  background: linear-gradient(#ee9ca7, #ffdde1);
  /* 将元素剪切微一个圆形【30%表示圆的直径】【right 70%表示圆心位置】 */
  clip-path: circle(20% at 10% 10%);
}
.container {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  z-index: 1;
}
.container .card {
  /* 相对定位 */
  position: relative;
  width: 280px;
  height: 400px;
  background-color: rgba(255, 255, 255, 0.1);
  margin: 30px;
  border-radius: 15px;
  /* 阴影 */
  box-shadow: 20px 20px 50px rgba(0, 0, 0, 0.5);
  /* 溢出隐藏 */
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  border-top: 1px solid rgba(255, 255, 255, 0.5);
  border-left: 1px solid rgba(255, 255, 255, 0.5);
  /* 背景模糊 */
  backdrop-filter: blur(5px);
}
.container .card .content {
  padding: 20px;
  text-align: center;
  /* 默认下移+隐藏 */
  /* transform: translateY(100px); */
  /* opacity: 0; */
  transition: 0.5s;
}
.container .card:hover .content {
  /* 鼠标移入，上移+显示 */
  transform: translateY(0);
  opacity: 1;
}
.container .card .content h2 {
  position: absolute;
  top: -80px;
  right: 25px;
  font-size: 128px;
  color: rgba(255, 255, 255, 0.05);
}
.container .card .content h3 {
  font-size: 28px;
  color: #fff;
}
.container .card .content p {
  font-size: 16px;
  color: #fff;
  font-weight: 300;
  margin: 10px 0 15px 0;
}
.container .card .content a {
  position: relative;
  display: inline-block;
  padding: 8px 20px;
  margin-top: 15px;
  background-color: #fff;
  color: #000;
  text-decoration: none;
  border-radius: 20px;
  font-weight: 500;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}
</style>